package com.youxuit.youxu.kecheng.threadLocal.usage2;


import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class OrderSimpleController {

    static ExecutorService executorService = Executors.newFixedThreadPool(10);

    public static void main(String[] args) {

        //new OrderSimpleController().process("22","22");
        for (int i = 0; i < 1000; i++) {

            int finalI = i;
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    new OrderSimpleController().process2("22", "我是王哥" + finalI);

                }
            });

        }

    }


    public void process(String orderId, String token) {

        //对token进行解析
        User user = new User();
        user.setName("王哥");
        new OrderSimpleManage().process(user);
    }

    public void process2(String orderId, String token) {

        //对token进行解析
        try {
            User user = new User();
            user.setName(token );
            UserContextHolder.userHolder.set(user);
            new OrderSimpleManage().process2();
        } finally {
            UserContextHolder.userHolder.remove();
        }
    }
}
